#include "dbhelper.h"
#include "DataBase/sqliteDb.h"
Dbhelper::Dbhelper()
{

    db = new sqliteDb();
    init_table_0 = R"(
                     CREATE TABLE IF NOT EXISTS  tb_user (
                     id   INTEGER   PRIMARY KEY AUTOINCREMENT NOT NULL,
                     name CHAR (50) NOT NULL,
                     age  INTEGER
                     );)";

}
Dbhelper::~Dbhelper()
{
    if(db!= nullptr){
        db->closeSql();
        delete db;
    }
}

int Dbhelper::createTable()
{
    db->setDbDir(DATA_PATH);
    bool ret = db->creatDbFile(DB_NAME);
    if(!ret){
        return -1;
    }
    ret = db->reOpenSql(DB_NAME);
    if(ret){
        db->queryExec(init_table_0);
    }

    return 0;
}
